package com.control.util;

import java.io.Serializable;
import java.util.List;

public class PageData<T> implements Serializable  {
    public PageData() {
    }

    public PageData(Integer pageIndex, Integer pageSize, Integer totalCount, List<T> data) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;
        this.totalPageCount = totalCount % pageSize == 0?
                totalCount / pageSize:totalCount / pageSize+1;
    }

    private Integer pageIndex;
    private Integer pageSize;
    private Integer totalCount;
    private Integer totalPageCount;
    private List<T> data;
    private Boolean hasPrevious;
    private Boolean hasNext;

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(Integer totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public Boolean getHasPrevious() {
        return this.pageIndex > 1;
    }

    public Boolean getHasNext() {
        return this.pageIndex < this.totalCount;
    }
}
